<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>注   册</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
</head>
<body>

<div id="app">
	<common>
		<div id="register" class="box">
			<h2>新用户注册</h2>
			<div class="content">
				<form method="post" action="reg_success.html">
					<dl>
						<dt>用户ID：</dt>
						<dd><input disabled type="text" class="input-text" name="userId" value=""/></dd>
						<dt>用户名：</dt>
						<dd><input v-model="uname" type="text" class="input-text" name="userName" value=""/></dd>
						<dt>密码：</dt>
						<dd><input v-model="pwd" type="password" class="input-text" name="password" value=""/></dd>
						<dt>确认密码：</dt>
						<dd><input v-model="repwd" type="password" class="input-text" name="confirmPassword" value=""/></dd>
						<dt></dt>
						<dd><input @click.prevent="reg" type="submit" class="input-button" name="submit" value="" /></dd>
					</dl>
				</form>
				<div class="error"></div>
				<div class="error"></div>
			</div>
		</div>
	</common>
</div>
<script src="js/vue.min.js"></script>
<script src="js/axios.min.js"></script>
<script src="js/vote.js"></script>
<script>
	var v = new Vue({
		el : "#app",
		data:{
			uname:"",
			pwd:"",
			repwd:""
		},
		methods:{
			reg(){
				let p = new URLSearchParams();
				p.append("uname", this.uname);
				p.append("pwd", this.pwd);
				p.append("repwd", this.repwd);
				axios.post("/demovote/user/register",p).then(res=>{
					if(res.data.code==1){
						location.href="login.html";
					} else {
						alert(res.data.msg);
					}
				})
			}
		}
	})
</script>
</body>
</html>
